package com.zzl.bonds.ticket.constant.type;

import com.zzl.bonds.ticket.dto.KeyValue;

import java.util.ArrayList;
import java.util.List;

/**
 * 发票类型枚举值：普票、专票
 *
 * @author : gull
 * @date : 2022/2/17 20:41
 */
public enum InvoiceTypeEnum {

    /**
     * 发票类型 0 专票 1普票
     */

    /**
     * 发票种类  验真伪时的枚举
     * 增值税专用发票：special_vat_invoice
     * 增值税电子专用发票：elec_special_vat_invoice
     * 增值税普通发票：normal_invoice
     * 增值税普通发票（电子）：elec_normal_invoice
     */
    TICKET(0, "专票", "special_vat_invoice"),

    /**
     * 发票
     */
    INVOICE(1, "普票", "normal_invoice");

    private Integer code;
    private String value;
    private String type;

    InvoiceTypeEnum(Integer code, String value, String type) {
        this.code = code;
        this.value = value;
        this.type = type;
    }


    public static String getType(Integer code) {
        for (InvoiceTypeEnum statusEnum : InvoiceTypeEnum.values()) {
            if (statusEnum.code.equals(code)) {
                return statusEnum.type;
            }
        }
        return "";
    }

    public static String getValue(Integer code) {
        for (InvoiceTypeEnum statusEnum : InvoiceTypeEnum.values()) {
            if (statusEnum.code.equals(code)) {
                return statusEnum.value;
            }
        }
        return "";
    }

    /**
     * 发票类型枚举
     *
     * @return 发票类型枚举
     */
    public static List<KeyValue> list() {
        List<KeyValue> list = new ArrayList<>();
        for (InvoiceTypeEnum invoiceTypeEnum : InvoiceTypeEnum.values()) {
            KeyValue keyValue = new KeyValue();
            keyValue.setKey(invoiceTypeEnum.code);
            keyValue.setValue(invoiceTypeEnum.value);
            list.add(keyValue);
        }
        return list;
    }


    public Integer getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    public String getType() {
        return type;
    }
}
